// 肉鸽系统 - 道具选择和渐进式强化
class RoguelikeSystem {
    constructor() {
        this.selectedUpgrades = []; // 本次游戏选择的升级
        this.permanentUpgrades = this.loadPermanentUpgrades(); // 永久升级
        this.currency = this.loadCurrency(); // 游戏货币
        this.upgradeDefinitions = this.createUpgradeDefinitions();
        this.permanentUpgradeDefinitions = this.createPermanentUpgradeDefinitions();
        
        // 当前生效的临时效果
        this.activeEffects = {
            damageMultiplier: 1,
            speedMultiplier: 1,
            healthMultiplier: 1,
            fireRateMultiplier: 1,
            accuracyBonus: 0,
            criticalChance: 0,
            criticalDamage: 1.5,
            lifesteal: 0,
            explosiveBullets: false,
            piercingBullets: false,
            homingBullets: false,
            damageTakenMultiplier: 1,
            ghostChance: 0,
            multiShot: 1,
            ricochetCount: 0,
            bulletTimeMode: false,
            elementalMastery: false,
            perfectBalance: false
        };
    }
    
    createUpgradeDefinitions() {
        return {
            // 攻击相关
            damageBoost: {
                name: '火力强化',
                description: '武器伤害+25%',
                icon: '💥',
                rarity: 'common',
                effect: () => {
                    this.activeEffects.damageMultiplier *= 1.25;
                    this.applyPlayerUpgrades();
                }
            },
            
            fireRateBoost: {
                name: '射速狂潮',
                description: '射击速度+30%',
                icon: '🔥',
                rarity: 'common',
                effect: () => {
                    this.activeEffects.fireRateMultiplier *= 1.3;
                    this.applyPlayerUpgrades();
                }
            },
            
            criticalStrike: {
                name: '致命打击',
                description: '15%暴击率，造成2倍伤害',
                icon: '⚡',
                rarity: 'rare',
                effect: () => {
                    this.activeEffects.criticalChance += 0.15;
                    this.activeEffects.criticalDamage = 2.0;
                    this.applyPlayerUpgrades();
                }
            },
            
            explosiveBullets: {
                name: '爆炸弹药',
                description: '子弹击中后产生爆炸',
                icon: '💣',
                rarity: 'epic',
                effect: () => {
                    this.activeEffects.explosiveBullets = true;
                    this.applyPlayerUpgrades();
                }
            },
            
            piercingShots: {
                name: '穿透射击',
                description: '子弹可以穿透敌人',
                icon: '🏹',
                rarity: 'rare',
                effect: () => {
                    this.activeEffects.piercingBullets = true;
                    this.applyPlayerUpgrades();
                }
            },
            
            homingBullets: {
                name: '追踪弹药',
                description: '子弹会自动追踪敌人',
                icon: '🎯',
                rarity: 'epic',
                effect: () => {
                    this.activeEffects.homingBullets = true;
                    this.applyPlayerUpgrades();
                }
            },
            
            // 防御相关
            healthBoost: {
                name: '血量强化',
                description: '最大血量+50%',
                icon: '❤️',
                rarity: 'common',
                effect: () => {
                    this.activeEffects.healthMultiplier *= 1.5;
                    this.applyPlayerUpgrades();
                }
            },
            
            speedBoost: {
                name: '疾风步伐',
                description: '移动速度+40%',
                icon: '💨',
                rarity: 'common',
                effect: () => {
                    this.activeEffects.speedMultiplier *= 1.4;
                    this.applyPlayerUpgrades();
                }
            },
            
            regeneration: {
                name: '生命回复',
                description: '每秒回复2点生命值',
                icon: '💚',
                rarity: 'rare',
                effect: () => {
                    this.startRegeneration();
                }
            },
            
            lifesteal: {
                name: '生命偷取',
                description: '击杀敌人回复10%最大生命',
                icon: '🩸',
                rarity: 'epic',
                effect: () => {
                    this.activeEffects.lifesteal = 0.1;
                    this.applyPlayerUpgrades();
                }
            },
            
            // 特殊效果
            timeWarp: {
                name: '时间扭曲',
                description: '敌人移动速度-50%',
                icon: '⏰',
                rarity: 'legendary',
                effect: () => {
                    this.applyTimeWarp();
                }
            },
            
            berserkerMode: {
                name: '狂战士模式',
                description: '血量越低伤害越高',
                icon: '😡',
                rarity: 'epic',
                effect: () => {
                    this.activateBerserkerMode();
                }
            },
            
            multiShot: {
                name: '多重射击',
                description: '每次射击发射3发子弹',
                icon: '🔫',
                rarity: 'rare',
                effect: () => {
                    this.activeEffects.multiShot = 3;
                    this.applyPlayerUpgrades();
                }
            },
            
            lucky: {
                name: '幸运之星',
                description: '获得金币+100%，掉落率提升',
                icon: '🍀',
                rarity: 'rare',
                effect: () => {
                    this.activeEffects.luckMultiplier = 2;
                    this.applyPlayerUpgrades();
                }
            },
            
            assassin: {
                name: '刺客之影',
                description: '背后攻击造成3倍伤害',
                icon: '🗡️',
                rarity: 'epic',
                effect: () => {
                    this.activeEffects.backstabMultiplier = 3;
                    this.applyPlayerUpgrades();
                }
            },
            
            shockwave: {
                name: '冲击波',
                description: '击杀敌人产生伤害波动',
                icon: '🌊',
                rarity: 'legendary',
                effect: () => {
                    this.activeEffects.shockwaveOnKill = true;
                    this.applyPlayerUpgrades();
                }
            },
            
            // 负面升级 - 为了平衡和策略性
            cursedPower: {
                name: '诅咒之力',
                description: '伤害+50%，但最大血量-25%',
                icon: '💀',
                rarity: 'cursed',
                effect: () => {
                    this.activeEffects.damageMultiplier *= 1.5;
                    this.activeEffects.healthMultiplier *= 0.75;
                    this.applyCursedHealthReduction();
                    this.applyPlayerUpgrades();
                }
            },
            
            berserkerCurse: {
                name: '狂战士诅咒',
                description: '攻击速度+80%，但精确度-30%',
                icon: '⚔️',
                rarity: 'cursed',
                effect: () => {
                    this.activeEffects.fireRateMultiplier *= 1.8;
                    this.activeEffects.accuracyBonus -= 0.3;
                    this.applyPlayerUpgrades();
                }
            },
            
            glassCannonMode: {
                name: '玻璃大炮',
                description: '所有伤害+100%，但受到伤害+50%',
                icon: '🔥',
                rarity: 'cursed',
                effect: () => {
                    this.activeEffects.damageMultiplier *= 2;
                    this.activeEffects.damageTakenMultiplier = 1.5;
                    this.applyPlayerUpgrades();
                }
            },
            
            // 协同效应升级
            elementalMastery: {
                name: '元素精通',
                description: '如果有爆炸或穿透，获得额外效果',
                icon: '🔮',
                rarity: 'legendary',
                effect: () => {
                    this.activeEffects.elementalMastery = true;
                    this.applyElementalSynergy();
                    this.applyPlayerUpgrades();
                }
            },
            
            perfectBalance: {
                name: '完美平衡',
                description: '每有一个负面效果，获得10%全属性提升',
                icon: '⚖️',
                rarity: 'legendary',
                effect: () => {
                    this.activeEffects.perfectBalance = true;
                    this.applyBalanceBonus();
                    this.applyPlayerUpgrades();
                }
            },
            
            // 更多独特升级
            bulletTime: {
                name: '子弹时间',
                description: '血量低于30%时触发慢动作',
                icon: '⏱️',
                rarity: 'epic',
                effect: () => {
                    this.activeEffects.bulletTimeMode = true;
                    this.applyPlayerUpgrades();
                }
            },
            
            ricochetMaster: {
                name: '弹射大师',
                description: '子弹可以弹射2次',
                icon: '🎯',
                rarity: 'rare',
                effect: () => {
                    this.activeEffects.ricochetCount = 2;
                    this.applyPlayerUpgrades();
                }
            },
            
            ghostMode: {
                name: '幽灵模式',
                description: '30%几率避免伤害，但伤害-20%',
                icon: '👻',
                rarity: 'rare',
                effect: () => {
                    this.activeEffects.ghostChance = 0.3;
                    this.activeEffects.damageMultiplier *= 0.8;
                    this.applyPlayerUpgrades();
                }
            }
        };
    }
    
    createPermanentUpgradeDefinitions() {
        return {
            // 基础属性永久升级
            permanentDamage: {
                name: '伤害强化',
                description: '永久增加基础武器伤害',
                icon: '⚔️',
                maxLevel: 10,
                costs: [50, 100, 200, 400, 800, 1600, 3200, 6400, 12800, 25600],
                effect: (level) => {
                    const damageBonus = level * 0.1; // 每级增加10%伤害
                    return { damageMultiplier: 1 + damageBonus };
                }
            },
            
            permanentHealth: {
                name: '生命强化',
                description: '永久增加基础生命值',
                icon: '💖',
                maxLevel: 10,
                costs: [40, 80, 160, 320, 640, 1280, 2560, 5120, 10240, 20480],
                effect: (level) => {
                    const healthBonus = level * 0.15; // 每级增加15%生命
                    return { healthMultiplier: 1 + healthBonus };
                }
            },
            
            permanentSpeed: {
                name: '速度强化',
                description: '永久增加移动速度',
                icon: '🏃',
                maxLevel: 8,
                costs: [60, 120, 240, 480, 960, 1920, 3840, 7680],
                effect: (level) => {
                    const speedBonus = level * 0.08; // 每级增加8%速度
                    return { speedMultiplier: 1 + speedBonus };
                }
            },
            
            permanentFireRate: {
                name: '射速强化',
                description: '永久增加射击速度',
                icon: '🔥',
                maxLevel: 8,
                costs: [80, 160, 320, 640, 1280, 2560, 5120, 10240],
                effect: (level) => {
                    const fireRateBonus = level * 0.12; // 每级增加12%射速
                    return { fireRateMultiplier: 1 + fireRateBonus };
                }
            },
            
            permanentCritical: {
                name: '暴击强化',
                description: '永久增加暴击率',
                icon: '💥',
                maxLevel: 5,
                costs: [200, 400, 800, 1600, 3200],
                effect: (level) => {
                    const critBonus = level * 0.05; // 每级增加5%暴击率
                    return { criticalChance: critBonus };
                }
            },
            
            permanentLuck: {
                name: '幸运强化',
                description: '永久增加金币获得和道具掉落',
                icon: '🍀',
                maxLevel: 5,
                costs: [150, 300, 600, 1200, 2400],
                effect: (level) => {
                    const luckBonus = level * 0.5; // 每级增加50%幸运
                    return { luckMultiplier: 1 + luckBonus };
                }
            },
            
            // 特殊永久升级
            permanentRegeneration: {
                name: '生命回复',
                description: '游戏开始时自动获得生命回复效果',
                icon: '💚',
                maxLevel: 1,
                costs: [1000],
                effect: (level) => {
                    return { hasRegeneration: true };
                }
            },
            
            permanentStartingWeapon: {
                name: '起始武器',
                description: '游戏开始时拥有更好的武器',
                icon: '🔫',
                maxLevel: 3,
                costs: [500, 1500, 3000],
                effect: (level) => {
                    const weapons = ['pistol', 'rifle', 'shotgun', 'smg'];
                    return { startingWeapon: weapons[level] };
                }
            },
            
            permanentExtraLife: {
                name: '额外生命',
                description: '每关开始时额外获得生命值',
                icon: '❤️‍🔥',
                maxLevel: 3,
                costs: [800, 2000, 4000],
                effect: (level) => {
                    const extraHealth = level * 25; // 每级增加25点生命
                    return { extraStartingHealth: extraHealth };
                }
            },
            
            permanentBulletPenetration: {
                name: '子弹穿透',
                description: '游戏开始时子弹可以穿透敌人',
                icon: '🏹',
                maxLevel: 1,
                costs: [2000],
                effect: (level) => {
                    return { hasPenetration: true };
                }
            }
        };
    }
    
    // 获取随机升级选项
    getRandomUpgrades(count = 3) {
        const availableUpgrades = Object.keys(this.upgradeDefinitions);
        const rarityWeights = {
            'common': 45,
            'rare': 25,
            'epic': 15,
            'legendary': 8,
            'cursed': 7  // 诅咒升级有一定概率出现
        };
        
        const selectedUpgrades = [];
        
        for (let i = 0; i < count; i++) {
            let attempts = 0;
            let upgrade;
            
            do {
                // 根据稀有度权重随机选择
                const randomRarity = this.weightedRandomRarity(rarityWeights);
                const upgradesOfRarity = availableUpgrades.filter(key => 
                    this.upgradeDefinitions[key].rarity === randomRarity
                );
                
                if (upgradesOfRarity.length > 0) {
                    const randomIndex = Math.floor(Math.random() * upgradesOfRarity.length);
                    upgrade = upgradesOfRarity[randomIndex];
                }
                
                attempts++;
            } while (selectedUpgrades.includes(upgrade) && attempts < 20);
            
            if (upgrade && !selectedUpgrades.includes(upgrade)) {
                selectedUpgrades.push(upgrade);
            }
        }
        
        return selectedUpgrades;
    }
    
    weightedRandomRarity(weights) {
        const totalWeight = Object.values(weights).reduce((sum, weight) => sum + weight, 0);
        let random = Math.random() * totalWeight;
        
        for (const [rarity, weight] of Object.entries(weights)) {
            random -= weight;
            if (random <= 0) {
                return rarity;
            }
        }
        
        return 'common'; // 默认返回普通稀有度
    }
    
    // 显示升级选择界面
    showUpgradeSelection() {
        const upgrades = this.getRandomUpgrades(3);
        this.createUpgradeSelectionUI(upgrades);
    }
    
    createUpgradeSelectionUI(upgrades) {
        // 创建升级选择界面
        const upgradeMenu = document.createElement('div');
        upgradeMenu.id = 'upgradeSelectionMenu';
        upgradeMenu.className = 'upgrade-selection-menu';
        
        upgradeMenu.innerHTML = `
            <div class="upgrade-selection-overlay">
                <div class="upgrade-selection-container">
                    <h2 class="upgrade-title">🎲 选择你的强化</h2>
                    <p class="upgrade-subtitle">选择一个升级来强化你的角色</p>
                    <div class="upgrade-cards">
                        ${upgrades.map(upgradeKey => this.createUpgradeCard(upgradeKey)).join('')}
                    </div>
                </div>
            </div>
        `;
        
        document.body.appendChild(upgradeMenu);
        
        // 添加点击事件 - 修复索引问题
        upgrades.forEach((upgradeKey, index) => {
            const card = upgradeMenu.querySelector(`[data-upgrade="${upgradeKey}"]`);
            if (card) {
                // 移除可能存在的旧事件监听器
                const newCard = card.cloneNode(true);
                card.parentNode.replaceChild(newCard, card);
                
                // 添加新的事件监听器 - 优化为单击立即响应
                newCard.addEventListener('click', (e) => {
                    e.preventDefault();
                    e.stopPropagation();
                    
                    // 防止重复点击
                    if (newCard.classList.contains('selected') || newCard.classList.contains('processing')) return;
                    
                    // 立即标记为处理中
                    newCard.classList.add('processing');
                    
                    // 禁用所有卡片点击
                    document.querySelectorAll('.upgrade-card').forEach(card => {
                        card.style.pointerEvents = 'none';
                    });
                    
                    // 添加选中动画
                    newCard.style.transform = 'scale(1.1)';
                    newCard.style.borderColor = '#00ff88';
                    newCard.style.boxShadow = '0 0 30px rgba(0, 255, 136, 0.8)';
                    
                    console.log(`选择升级: ${upgradeKey}`);
                    this.selectUpgrade(upgradeKey);
                    
                    // 立即关闭界面
                    setTimeout(() => {
                        this.closeUpgradeSelection();
                    }, 150);
                });
                
                // 添加悬停效果
                newCard.addEventListener('mouseenter', () => {
                    if (!newCard.classList.contains('selected')) {
                        newCard.style.transform = 'translateY(-10px) scale(1.05)';
                    }
                });
                
                newCard.addEventListener('mouseleave', () => {
                    if (!newCard.classList.contains('selected')) {
                        newCard.style.transform = 'translateY(0) scale(1)';
                    }
                });
            }
        });
        
        // 添加样式
        this.addUpgradeSelectionStyles();
    }
    
    createUpgradeCard(upgradeKey) {
        const upgrade = this.upgradeDefinitions[upgradeKey];
        
        const rarityColors = {
            'common': '#ffffff',
            'rare': '#3498db',
            'epic': '#9b59b6',
            'legendary': '#f39c12',
            'cursed': '#8b0000'
        };
        
        const rarityGradients = {
            'common': 'linear-gradient(135deg, rgba(255,255,255,0.1), rgba(200,200,200,0.1))',
            'rare': 'linear-gradient(135deg, rgba(52,152,219,0.2), rgba(41,128,185,0.1))',
            'epic': 'linear-gradient(135deg, rgba(155,89,182,0.2), rgba(142,68,173,0.1))',
            'legendary': 'linear-gradient(135deg, rgba(243,156,18,0.3), rgba(230,126,34,0.2))',
            'cursed': 'linear-gradient(135deg, rgba(139,0,0,0.3), rgba(139,0,0,0.1))'
        };
        
        const rarityLabels = {
            'common': '普通',
            'rare': '稀有',
            'epic': '史诗',
            'legendary': '传说',
            'cursed': '诅咒'
        };
        
        const synergies = this.checkSynergies(upgradeKey);
        const synergyHint = synergies.length > 0 ? `<div class="synergy-hint">协同: ${synergies.join(', ')}</div>` : '';
        
        return `
            <div class="upgrade-card ${upgrade.rarity}" 
                 data-upgrade="${upgradeKey}" 
                 style="border-color: ${rarityColors[upgrade.rarity]}; background: ${rarityGradients[upgrade.rarity]}">
                <div class="upgrade-rarity-badge ${upgrade.rarity}">${rarityLabels[upgrade.rarity]}</div>
                <div class="upgrade-icon">${upgrade.icon}</div>
                <h3 class="upgrade-name">${upgrade.name}</h3>
                <p class="upgrade-description">${upgrade.description}</p>
                ${synergyHint}
                <div class="upgrade-select-hint">点击选择</div>
            </div>
        `;
    }
    
    addUpgradeSelectionStyles() {
        if (document.getElementById('upgradeSelectionStyles')) return;
        
        const styles = document.createElement('style');
        styles.id = 'upgradeSelectionStyles';
        styles.textContent = `
            .upgrade-selection-menu {
                position: fixed;
                top: 0;
                left: 0;
                width: 100%;
                height: 100%;
                z-index: 10000;
                display: flex;
                align-items: center;
                justify-content: center;
                animation: upgradeMenuEntry 0.8s ease-out;
            }
            
            .upgrade-selection-overlay {
                position: absolute;
                top: 0;
                left: 0;
                width: 100%;
                height: 100%;
                background: linear-gradient(135deg, 
                    rgba(0, 0, 0, 0.95), 
                    rgba(20, 10, 40, 0.95),
                    rgba(40, 20, 60, 0.95)
                );
                backdrop-filter: blur(15px);
                animation: overlayGlow 0.8s ease-out;
            }
            
            .upgrade-selection-overlay::before {
                content: '';
                position: absolute;
                top: 0;
                left: 0;
                right: 0;
                bottom: 0;
                background: 
                    radial-gradient(circle at 20% 80%, rgba(255, 107, 107, 0.1) 0%, transparent 50%),
                    radial-gradient(circle at 80% 20%, rgba(255, 215, 0, 0.1) 0%, transparent 50%),
                    radial-gradient(circle at 40% 40%, rgba(0, 255, 136, 0.1) 0%, transparent 50%);
                animation: backgroundPulse 4s ease-in-out infinite;
            }
            
            .upgrade-selection-container {
                position: fixed;
                top: 50%;
                left: 50%;
                transform: translate(-50%, -50%);
                z-index: 10001;
                text-align: center;
                padding: 50px;
                max-width: 1200px;
                background: rgba(15, 15, 15, 0.95);
                border-radius: 25px;
                border: 3px solid rgba(255, 107, 107, 0.5);
                box-shadow: 
                    0 0 50px rgba(0, 0, 0, 0.9),
                    inset 0 0 30px rgba(255, 107, 107, 0.1);
                animation: containerStableAppear 0.3s ease-out;
            }
            
            .upgrade-title {
                font-size: 42px;
                color: #fff;
                margin-bottom: 15px;
                text-shadow: 
                    0 0 20px rgba(255, 255, 255, 0.8),
                    0 0 40px rgba(255, 215, 0, 0.6),
                    0 0 60px rgba(255, 107, 107, 0.4);
                animation: titleGlow 3s ease-in-out infinite;
                font-family: 'Courier New', monospace;
                letter-spacing: 3px;
                background: linear-gradient(45deg, #fff, #ffd700, #ff6b6b, #fff);
                background-size: 300% 300%;
                -webkit-background-clip: text;
                background-clip: text;
                -webkit-text-fill-color: transparent;
                animation: titleGradient 4s ease-in-out infinite, titleGlow 3s ease-in-out infinite;
            }
            
            .upgrade-subtitle {
                font-size: 20px;
                color: #ddd;
                margin-bottom: 50px;
                text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
                animation: subtitleFade 0.8s ease-out 0.3s both;
            }
            
            .upgrade-cards {
                display: flex;
                gap: 40px;
                justify-content: center;
                flex-wrap: wrap;
                perspective: 1000px;
            }
            
            .upgrade-card {
                background: linear-gradient(135deg, 
                    rgba(20, 20, 20, 0.95), 
                    rgba(40, 40, 40, 0.95),
                    rgba(60, 60, 60, 0.95)
                );
                border: 3px solid;
                border-radius: 20px;
                padding: 30px;
                width: 280px;
                height: 360px;
                cursor: pointer;
                transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
                position: relative;
                overflow: hidden;
                animation: cardEntry 0.4s ease-out;
                box-shadow: 
                    0 10px 30px rgba(0, 0, 0, 0.3),
                    inset 0 1px 0 rgba(255, 255, 255, 0.1);
                transform-style: preserve-3d;
            }
            
            .upgrade-card:nth-child(1) { animation-delay: 0.05s; }
            .upgrade-card:nth-child(2) { animation-delay: 0.1s; }
            .upgrade-card:nth-child(3) { animation-delay: 0.15s; }
            
            .upgrade-card:hover {
                transform: translateY(-15px) scale(1.08) rotateX(5deg);
                box-shadow: 
                    0 25px 60px rgba(0, 0, 0, 0.4),
                    inset 0 1px 0 rgba(255, 255, 255, 0.2);
            }
            
            .upgrade-card::before {
                content: '';
                position: absolute;
                top: 0;
                left: -100%;
                width: 100%;
                height: 100%;
                background: linear-gradient(90deg, 
                    transparent, 
                    rgba(255, 255, 255, 0.15), 
                    transparent
                );
                transition: left 0.6s ease;
                z-index: 1;
            }
            
            .upgrade-card:hover::before {
                left: 100%;
            }
            
            .upgrade-card::after {
                content: '';
                position: absolute;
                top: 50%;
                left: 50%;
                width: 0;
                height: 0;
                background: radial-gradient(circle, rgba(255, 255, 255, 0.1), transparent);
                transform: translate(-50%, -50%);
                transition: width 0.3s ease, height 0.3s ease;
                border-radius: 50%;
                z-index: 0;
            }
            
            .upgrade-card:active::after {
                width: 300px;
                height: 300px;
            }
            
            .upgrade-icon {
                font-size: 56px;
                margin-bottom: 20px;
                filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.4));
                animation: iconFloat 3s ease-in-out infinite;
                position: relative;
                z-index: 2;
            }
            
            .upgrade-name {
                font-size: 22px;
                color: #fff;
                margin-bottom: 15px;
                font-weight: bold;
                text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
                position: relative;
                z-index: 2;
            }
            
            .upgrade-description {
                font-size: 15px;
                color: #ddd;
                line-height: 1.5;
                margin-bottom: 20px;
                text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
                position: relative;
                z-index: 2;
            }
            
            .upgrade-rarity {
                position: absolute;
                top: 15px;
                right: 15px;
                padding: 8px 15px;
                border-radius: 25px;
                font-size: 11px;
                font-weight: bold;
                text-transform: uppercase;
                letter-spacing: 1px;
                z-index: 3;
                border: 2px solid;
            }
            
            .upgrade-rarity.common {
                background: linear-gradient(45deg, rgba(255, 255, 255, 0.2), rgba(200, 200, 200, 0.2));
                color: #fff;
                border-color: #fff;
                animation: commonGlow 2s ease-in-out infinite;
            }
            
            .upgrade-rarity.rare {
                background: linear-gradient(45deg, rgba(52, 152, 219, 0.3), rgba(41, 128, 185, 0.3));
                color: #3498db;
                border-color: #3498db;
                animation: rareGlow 2s ease-in-out infinite;
            }
            
            .upgrade-rarity.epic {
                background: linear-gradient(45deg, rgba(155, 89, 182, 0.3), rgba(142, 68, 173, 0.3));
                color: #9b59b6;
                border-color: #9b59b6;
                animation: epicGlow 2s ease-in-out infinite;
            }
            
            .upgrade-rarity.legendary {
                background: linear-gradient(45deg, 
                    rgba(243, 156, 18, 0.4), 
                    rgba(230, 126, 34, 0.4),
                    rgba(255, 215, 0, 0.4)
                );
                color: #f39c12;
                border-color: #ffd700;
                animation: legendaryGlow 1.5s ease-in-out infinite;
                box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
            }
            
            /* 新增动画效果 */
            @keyframes upgradeMenuEntry {
                0% { 
                    opacity: 0; 
                    transform: scale(0.8); 
                }
                100% { 
                    opacity: 1; 
                    transform: scale(1); 
                }
            }
            
            @keyframes overlayGlow {
                0% { 
                    opacity: 0; 
                    filter: blur(20px); 
                }
                100% { 
                    opacity: 1; 
                    filter: blur(15px); 
                }
            }
            
            @keyframes backgroundPulse {
                0%, 100% { opacity: 0.8; }
                50% { opacity: 1; }
            }
            
            @keyframes containerStableAppear {
                0% { 
                    opacity: 0; 
                    transform: translate(-50%, -50%) scale(0.7);
                }
                60% {
                    opacity: 1;
                    transform: translate(-50%, -50%) scale(1.05);
                }
                100% { 
                    opacity: 1; 
                    transform: translate(-50%, -50%) scale(1);
                }
            }
            
            @keyframes titleGradient {
                0% { background-position: 0% 50%; }
                50% { background-position: 100% 50%; }
                100% { background-position: 0% 50%; }
            }
            
            @keyframes titleGlow {
                0%, 100% { 
                    text-shadow: 
                        0 0 20px rgba(255, 255, 255, 0.8),
                        0 0 40px rgba(255, 215, 0, 0.6),
                        0 0 60px rgba(255, 107, 107, 0.4);
                }
                50% { 
                    text-shadow: 
                        0 0 30px rgba(255, 255, 255, 1),
                        0 0 60px rgba(255, 215, 0, 0.8),
                        0 0 90px rgba(255, 107, 107, 0.6);
                }
            }
            
            @keyframes subtitleFade {
                0% { 
                    opacity: 0; 
                    transform: translateY(20px); 
                }
                100% { 
                    opacity: 1; 
                    transform: translateY(0); 
                }
            }
            
            @keyframes cardEntry {
                0% { 
                    opacity: 0; 
                    transform: translateY(50px) rotateX(-15deg); 
                }
                100% { 
                    opacity: 1; 
                    transform: translateY(0) rotateX(0deg); 
                }
            }
            
            @keyframes iconFloat {
                0%, 100% { transform: translateY(0px); }
                50% { transform: translateY(-8px); }
            }
            
            @keyframes commonGlow {
                0%, 100% { 
                    box-shadow: 0 0 10px rgba(255, 255, 255, 0.3); 
                }
                50% { 
                    box-shadow: 0 0 20px rgba(255, 255, 255, 0.6); 
                }
            }
            
            @keyframes rareGlow {
                0%, 100% { 
                    box-shadow: 0 0 10px rgba(52, 152, 219, 0.5); 
                }
                50% { 
                    box-shadow: 0 0 25px rgba(52, 152, 219, 0.8); 
                }
            }
            
            @keyframes epicGlow {
                0%, 100% { 
                    box-shadow: 0 0 15px rgba(155, 89, 182, 0.5); 
                }
                50% { 
                    box-shadow: 0 0 30px rgba(155, 89, 182, 0.8); 
                }
            }
            
            @keyframes legendaryGlow {
                0%, 100% { 
                    box-shadow: 
                        0 0 20px rgba(255, 215, 0, 0.6),
                        0 0 40px rgba(243, 156, 18, 0.4); 
                }
                50% { 
                    box-shadow: 
                        0 0 40px rgba(255, 215, 0, 1),
                        0 0 80px rgba(243, 156, 18, 0.6); 
                }
            }
            
            @keyframes shimmer {
                0% { background-position: -200% 0; }
                100% { background-position: 200% 0; }
            }
            
            @keyframes fadeIn {
                from { opacity: 0; }
                to { opacity: 1; }
            }
            
            @keyframes fadeOut {
                from { opacity: 1; }
                to { opacity: 0; }
            }
            
            @keyframes slideUp {
                from { 
                    opacity: 0;
                    transform: translateY(50px);
                }
                to { 
                    opacity: 1;
                    transform: translateY(0);
                }
            }
            
            @keyframes glow {
                from { text-shadow: 0 0 20px rgba(255, 255, 255, 0.5); }
                to { text-shadow: 0 0 30px rgba(255, 255, 255, 0.8); }
            }
            
            @keyframes shimmer {
                0%, 100% { filter: brightness(1); }
                50% { filter: brightness(1.3); }
            }
            
            .synergy-hint {
                background: rgba(0, 255, 136, 0.2);
                border: 1px solid #00ff88;
                border-radius: 8px;
                padding: 5px 8px;
                margin-top: 10px;
                font-size: 11px;
                color: #00ff88;
                text-align: center;
            }
            
            .upgrade-card.cursed {
                animation: cursedPulse 2s ease-in-out infinite;
            }
            
            @keyframes cursedPulse {
                0%, 100% { 
                    box-shadow: 0 0 10px rgba(139, 0, 0, 0.5);
                }
                50% { 
                    box-shadow: 0 0 25px rgba(139, 0, 0, 0.8);
                }
            }
        `;
        
        document.head.appendChild(styles);
    }
    
    selectUpgrade(upgradeKey) {
        const upgrade = this.upgradeDefinitions[upgradeKey];
        if (upgrade) {
            this.selectedUpgrades.push(upgradeKey);
            upgrade.effect();
            
            // 显示选择确认
            this.showUpgradeConfirmation(upgrade);
            console.log(`选择了升级: ${upgrade.name}`);
        }
    }
    
    showUpgradeConfirmation(upgrade) {
        const confirmation = document.createElement('div');
        confirmation.className = 'upgrade-confirmation';
        confirmation.innerHTML = `
            <div class="upgrade-confirmation-content">
                <div class="upgrade-confirmation-icon">${upgrade.icon}</div>
                <h3>获得升级！</h3>
                <p>${upgrade.name}</p>
                <div class="upgrade-description-small">${upgrade.description}</div>
            </div>
        `;
        
        document.body.appendChild(confirmation);
        
        // 添加样式
        if (!document.getElementById('upgradeConfirmationStyles')) {
            const styles = document.createElement('style');
            styles.id = 'upgradeConfirmationStyles';
            styles.textContent = `
                .upgrade-confirmation {
                    position: fixed;
                    top: 30%;
                    left: 50%;
                    transform: translate(-50%, -50%);
                    z-index: 15000;
                    animation: upgradePopIn 0.4s ease-out;
                }
                
                .upgrade-confirmation-content {
                    background: linear-gradient(135deg, rgba(0, 255, 136, 0.3), rgba(0, 255, 136, 0.1));
                    border: 2px solid #00ff88;
                    border-radius: 15px;
                    padding: 20px 25px;
                    text-align: center;
                    color: white;
                    box-shadow: 0 0 30px rgba(0, 255, 136, 0.5);
                    min-width: 250px;
                }
                
                .upgrade-confirmation-icon {
                    font-size: 48px;
                    margin-bottom: 10px;
                    animation: bounce 0.4s ease-out;
                }
                
                .upgrade-description-small {
                    font-size: 12px;
                    color: #ccc;
                    margin-top: 8px;
                    opacity: 0.8;
                }
                
                @keyframes upgradePopIn {
                    0% { 
                        opacity: 0;
                        transform: translate(-50%, -50%) scale(0.7);
                    }
                    100% { 
                        opacity: 1;
                        transform: translate(-50%, -50%) scale(1);
                    }
                }
                
                @keyframes bounce {
                    0%, 100% { transform: translateY(0); }
                    50% { transform: translateY(-5px); }
                }
            `;
            document.head.appendChild(styles);
        }
        
        // 1秒后移除确认界面
        setTimeout(() => {
            if (confirmation.parentNode) {
                confirmation.style.animation = 'fadeOut 0.3s ease-out';
                setTimeout(() => {
                    if (confirmation.parentNode) {
                        document.body.removeChild(confirmation);
                    }
                }, 300);
            }
        }, 1000);
    }
    
    closeUpgradeSelection() {
        const upgradeMenu = document.getElementById('upgradeSelectionMenu');
        if (upgradeMenu) {
            upgradeMenu.style.animation = 'fadeOut 0.2s ease-in';
            setTimeout(() => {
                if (upgradeMenu.parentNode) {
                    document.body.removeChild(upgradeMenu);
                }
            }, 200);
        }
    }
    
    // 应用所有升级到玩家
    applyPlayerUpgrades() {
        if (!window.player) return;
        
        // 应用伤害倍率
        if (window.player.currentWeapon) {
            window.player.currentWeapon.baseDamage = window.player.currentWeapon.baseDamage || window.player.currentWeapon.damage;
            window.player.currentWeapon.damage = Math.floor(window.player.currentWeapon.baseDamage * this.activeEffects.damageMultiplier);
        }
        
        // 应用速度倍率
        window.player.baseSpeed = window.player.baseSpeed || window.player.speed;
        window.player.speed = window.player.baseSpeed * this.activeEffects.speedMultiplier;
        
        // 应用血量倍率
        if (this.activeEffects.healthMultiplier !== 1 && !this.healthApplied) {
            window.player.baseMaxHealth = window.player.baseMaxHealth || window.player.maxHealth;
            const oldMaxHealth = window.player.maxHealth;
            window.player.maxHealth = Math.floor(window.player.baseMaxHealth * this.activeEffects.healthMultiplier);
            
            // 按比例调整当前血量
            const healthRatio = window.player.health / oldMaxHealth;
            window.player.health = Math.floor(window.player.maxHealth * healthRatio);
            window.player.updateHealthUI();
            
            this.healthApplied = true;
        }
        
        // 应用特殊效果
        if (this.activeEffects.bulletTimeMode) {
            window.player.bulletTimeMode = true;
        }
        
        if (this.activeEffects.ghostChance) {
            window.player.ghostChance = this.activeEffects.ghostChance;
        }
        
        if (this.activeEffects.damageTakenMultiplier) {
            window.player.damageTakenMultiplier = this.activeEffects.damageTakenMultiplier;
        }
        
        if (this.activeEffects.multiShot > 1) {
            window.player.multiShot = this.activeEffects.multiShot;
        }
        
        if (this.activeEffects.ricochetCount > 0) {
            window.player.ricochetCount = this.activeEffects.ricochetCount;
        }
        
        console.log('应用升级效果:', this.activeEffects);
    }
    
    // 特殊效果实现
    startRegeneration() {
        if (this.regenerationInterval) return;
        
        this.regenerationInterval = setInterval(() => {
            if (window.player && window.player.health < window.player.maxHealth) {
                window.player.health = Math.min(window.player.maxHealth, window.player.health + 2);
                window.player.updateHealthUI();
            }
        }, 1000);
    }
    
    applyTimeWarp() {
        if (window.gameEngine && window.gameEngine.zombies) {
            window.gameEngine.zombies.forEach(zombie => {
                zombie.baseSpeed = zombie.baseSpeed || zombie.speed;
                zombie.speed = zombie.baseSpeed * 0.5;
            });
        }
    }
    
    activateBerserkerMode() {
        this.berserkerModeActive = true;
        // 狂战士模式将在战斗时动态计算伤害加成
    }
    
    // 计算狂战士模式伤害加成
    getBerserkerDamageMultiplier() {
        if (!this.berserkerModeActive || !window.player) return 1;
        
        const healthPercent = window.player.health / window.player.maxHealth;
        const damageBonus = (1 - healthPercent) * 2; // 血量越低伤害加成越高
        return 1 + damageBonus;
    }
    
    // 重置临时效果（新游戏开始时调用）
    resetTemporaryEffects() {
        this.selectedUpgrades = [];
        this.activeEffects = {
            damageMultiplier: 1,
            speedMultiplier: 1,
            healthMultiplier: 1,
            fireRateMultiplier: 1,
            accuracyBonus: 0,
            criticalChance: 0,
            criticalDamage: 1.5,
            lifesteal: 0,
            explosiveBullets: false,
            piercingBullets: false,
            homingBullets: false
        };
        
        this.healthApplied = false;
        
        if (this.regenerationInterval) {
            clearInterval(this.regenerationInterval);
            this.regenerationInterval = null;
        }
    }
    
    // 保存和加载永久升级
    loadPermanentUpgrades() {
        const saved = localStorage.getItem('zombieGamePermanentUpgrades');
        return saved ? JSON.parse(saved) : {};
    }
    
    savePermanentUpgrades() {
        localStorage.setItem('zombieGamePermanentUpgrades', JSON.stringify(this.permanentUpgrades));
    }
    
    loadCurrency() {
        const saved = localStorage.getItem('zombieGameCurrency');
        return saved ? parseInt(saved) : 0;
    }
    
    saveCurrency() {
        localStorage.setItem('zombieGameCurrency', this.currency.toString());
    }
    
    // 获取当前货币
    getCurrency() {
        return this.currency;
    }
    
    // 添加货币
    addCurrency(amount) {
        this.currency += amount;
        this.saveCurrency();
    }
    
    // 消费货币
    spendCurrency(amount) {
        if (this.currency >= amount) {
            this.currency -= amount;
            this.saveCurrency();
            return true;
        }
        return false;
    }
    
    // 永久升级商店相关方法
    openUpgradeStore() {
        this.createUpgradeStoreUI();
        document.getElementById('upgradeStoreMenu').classList.remove('hidden');
        document.getElementById('startMenu').classList.add('hidden');
    }
    
    closeUpgradeStore() {
        document.getElementById('upgradeStoreMenu').classList.add('hidden');
        document.getElementById('startMenu').classList.remove('hidden');
    }
    
    createUpgradeStoreUI() {
        const storeGrid = document.getElementById('upgradeStoreGrid');
        const currencyDisplay = document.getElementById('currencyAmount');
        
        if (currencyDisplay) {
            currencyDisplay.textContent = this.currency;
        }
        
        if (!storeGrid) return;
        
        const upgradeCards = Object.entries(this.permanentUpgradeDefinitions).map(([key, upgrade]) => {
            const currentLevel = this.permanentUpgrades[key] || 0;
            const isMaxLevel = currentLevel >= upgrade.maxLevel;
            const cost = isMaxLevel ? 0 : upgrade.costs[currentLevel];
            const canAfford = this.currency >= cost;
            
            return `
                <div class="permanent-upgrade-card ${isMaxLevel ? 'max-level' : ''} ${canAfford ? 'affordable' : 'expensive'}" 
                     data-upgrade="${key}">
                    <div class="upgrade-card-header">
                        <div class="upgrade-icon">${upgrade.icon}</div>
                        <div class="upgrade-level">${currentLevel}/${upgrade.maxLevel}</div>
                    </div>
                    <h3 class="upgrade-name">${upgrade.name}</h3>
                    <p class="upgrade-description">${upgrade.description}</p>
                    <div class="upgrade-progress-bar">
                        <div class="progress-fill" style="width: ${(currentLevel / upgrade.maxLevel) * 100}%"></div>
                    </div>
                    <div class="upgrade-cost">
                        ${isMaxLevel ? 
                            '<span class="max-level-text">已满级</span>' : 
                            `<span class="cost-icon">💰</span><span class="cost-amount">${cost}</span>`
                        }
                    </div>
                    ${!isMaxLevel ? `<button class="buy-button ${canAfford ? '' : 'disabled'}" 
                                     onclick="window.roguelikeSystem.buyPermanentUpgrade('${key}')"
                                     ${canAfford ? '' : 'disabled'}>
                                     ${canAfford ? '购买' : '金币不足'}
                                   </button>` : ''}
                </div>
            `;
        }).join('');
        
        storeGrid.innerHTML = upgradeCards;
        
        // 添加商店样式
        this.addUpgradeStoreStyles();
    }
    
    addUpgradeStoreStyles() {
        if (document.getElementById('upgradeStoreStyles')) return;
        
        const styles = document.createElement('style');
        styles.id = 'upgradeStoreStyles';
        styles.textContent = `
            .currency-display {
                text-align: center;
                margin: 20px 0;
                font-size: 24px;
                color: #ffd700;
                background: rgba(0, 0, 0, 0.3);
                padding: 15px;
                border-radius: 10px;
                border: 2px solid #ffd700;
            }
            
            .currency-icon {
                font-size: 28px;
                margin-right: 10px;
            }
            
            .currency-label {
                margin-left: 10px;
                color: #fff;
            }
            
            .upgrade-store-grid {
                display: grid;
                grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
                gap: 20px;
                margin: 20px 0;
                max-height: 60vh;
                overflow-y: auto;
                padding: 20px;
            }
            
            .permanent-upgrade-card {
                background: linear-gradient(135deg, rgba(30, 30, 30, 0.9), rgba(50, 50, 50, 0.9));
                border: 2px solid #555;
                border-radius: 15px;
                padding: 20px;
                transition: all 0.3s ease;
                position: relative;
            }
            
            .permanent-upgrade-card.affordable {
                border-color: #00ff88;
            }
            
            .permanent-upgrade-card.expensive {
                border-color: #ff6b6b;
            }
            
            .permanent-upgrade-card.max-level {
                border-color: #ffd700;
                background: linear-gradient(135deg, rgba(255, 215, 0, 0.1), rgba(50, 50, 50, 0.9));
            }
            
            .permanent-upgrade-card:hover {
                transform: translateY(-5px);
                box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
            }
            
            .upgrade-card-header {
                display: flex;
                justify-content: space-between;
                align-items: center;
                margin-bottom: 15px;
            }
            
            .upgrade-icon {
                font-size: 32px;
                filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
            }
            
            .upgrade-level {
                background: rgba(255, 255, 255, 0.1);
                color: #fff;
                padding: 5px 10px;
                border-radius: 15px;
                font-size: 12px;
                font-weight: bold;
            }
            
            .upgrade-name {
                color: #fff;
                font-size: 18px;
                margin: 0 0 10px 0;
                font-weight: bold;
            }
            
            .upgrade-description {
                color: #ccc;
                font-size: 14px;
                line-height: 1.4;
                margin-bottom: 15px;
            }
            
            .upgrade-progress-bar {
                width: 100%;
                height: 6px;
                background: rgba(255, 255, 255, 0.2);
                border-radius: 3px;
                overflow: hidden;
                margin-bottom: 15px;
            }
            
            .progress-fill {
                height: 100%;
                background: linear-gradient(90deg, #00ff88, #4ecdc4);
                transition: width 0.3s ease;
            }
            
            .upgrade-cost {
                display: flex;
                align-items: center;
                justify-content: center;
                margin-bottom: 15px;
                font-size: 18px;
                font-weight: bold;
            }
            
            .cost-icon {
                margin-right: 5px;
            }
            
            .cost-amount {
                color: #ffd700;
            }
            
            .max-level-text {
                color: #ffd700;
                font-style: italic;
            }
            
            .buy-button {
                width: 100%;
                padding: 10px;
                background: linear-gradient(135deg, #00ff88, #4ecdc4);
                border: none;
                border-radius: 8px;
                color: #fff;
                font-size: 16px;
                font-weight: bold;
                cursor: pointer;
                transition: all 0.3s ease;
            }
            
            .buy-button:hover:not(.disabled) {
                transform: translateY(-2px);
                box-shadow: 0 5px 15px rgba(0, 255, 136, 0.3);
            }
            
            .buy-button.disabled {
                background: #666;
                cursor: not-allowed;
                opacity: 0.5;
            }
            
            .store-controls {
                text-align: center;
                margin-top: 20px;
            }
        `;
        
        document.head.appendChild(styles);
    }
    
    buyPermanentUpgrade(upgradeKey) {
        const upgrade = this.permanentUpgradeDefinitions[upgradeKey];
        if (!upgrade) return;
        
        const currentLevel = this.permanentUpgrades[upgradeKey] || 0;
        if (currentLevel >= upgrade.maxLevel) return;
        
        const cost = upgrade.costs[currentLevel];
        if (!this.spendCurrency(cost)) return;
        
        // 升级
        this.permanentUpgrades[upgradeKey] = currentLevel + 1;
        this.savePermanentUpgrades();
        
        // 刷新界面
        this.createUpgradeStoreUI();
        
        // 显示购买确认
        this.showPurchaseConfirmation(upgrade);
        
        console.log(`购买永久升级: ${upgrade.name} (等级 ${currentLevel + 1})`);
    }
    
    showPurchaseConfirmation(upgrade) {
        const confirmation = document.createElement('div');
        confirmation.className = 'purchase-confirmation';
        confirmation.innerHTML = `
            <div class="purchase-confirmation-content">
                <div class="purchase-confirmation-icon">${upgrade.icon}</div>
                <h3>升级成功！</h3>
                <p>${upgrade.name}</p>
            </div>
        `;
        
        document.body.appendChild(confirmation);
        
        // 添加样式
        if (!document.getElementById('purchaseConfirmationStyles')) {
            const styles = document.createElement('style');
            styles.id = 'purchaseConfirmationStyles';
            styles.textContent = `
                .purchase-confirmation {
                    position: fixed;
                    top: 50%;
                    left: 50%;
                    transform: translate(-50%, -50%);
                    z-index: 15000;
                    animation: purchasePopIn 1s ease-out;
                }
                
                .purchase-confirmation-content {
                    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 215, 0, 0.1));
                    border: 2px solid #ffd700;
                    border-radius: 15px;
                    padding: 30px;
                    text-align: center;
                    color: white;
                    box-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
                }
                
                .purchase-confirmation-icon {
                    font-size: 64px;
                    margin-bottom: 15px;
                    animation: bounce 0.6s ease-out;
                }
                
                @keyframes purchasePopIn {
                    0% { 
                        opacity: 0;
                        transform: translate(-50%, -50%) scale(0.5);
                    }
                    80% {
                        transform: translate(-50%, -50%) scale(1.1);
                    }
                    100% { 
                        opacity: 1;
                        transform: translate(-50%, -50%) scale(1);
                    }
                }
            `;
            document.head.appendChild(styles);
        }
        
        // 2秒后移除确认界面
        setTimeout(() => {
            if (confirmation.parentNode) {
                document.body.removeChild(confirmation);
            }
        }, 2000);
    }
    
    // 更新商店UI
    updateStoreUI() {
        this.createUpgradeStoreUI();
    }
    
    // 应用永久升级效果
    applyPermanentUpgrades() {
        // 重置为基础倍率
        this.resetActiveEffects();
        
        Object.entries(this.permanentUpgrades).forEach(([key, level]) => {
            if (level > 0) {
                const upgrade = this.permanentUpgradeDefinitions[key];
                if (upgrade) {
                    const effects = upgrade.effect(level);
                    
                    // 应用永久效果到基础属性
                    Object.entries(effects).forEach(([effectKey, effectValue]) => {
                        switch (effectKey) {
                            case 'damageMultiplier':
                                this.activeEffects.damageMultiplier *= effectValue;
                                break;
                            case 'healthMultiplier':
                                this.activeEffects.healthMultiplier *= effectValue;
                                break;
                            case 'speedMultiplier':
                                this.activeEffects.speedMultiplier *= effectValue;
                                break;
                            case 'fireRateMultiplier':
                                this.activeEffects.fireRateMultiplier *= effectValue;
                                break;
                            case 'criticalChance':
                                this.activeEffects.criticalChance += effectValue;
                                break;
                            case 'luckMultiplier':
                                this.activeEffects.luckMultiplier = effectValue;
                                break;
                            case 'hasRegeneration':
                                this.startRegeneration();
                                break;
                        }
                    });
                }
            }
        });
        
        // 关键：应用到玩家属性
        this.applyPlayerUpgrades();
        console.log('永久升级已应用到玩家属性');
    }
    
    // 重置活跃效果到基础值
    resetActiveEffects() {
        this.activeEffects = {
            damageMultiplier: 1,
            speedMultiplier: 1,
            healthMultiplier: 1,
            fireRateMultiplier: 1,
            accuracyBonus: 0,
            criticalChance: 0,
            criticalDamage: 1.5,
            lifesteal: 0,
            explosiveBullets: false,
            piercingBullets: false,
            homingBullets: false,
            damageTakenMultiplier: 1,
            ghostChance: 0,
            multiShot: 1,
            ricochetCount: 0,
            bulletTimeMode: false,
            elementalMastery: false,
            perfectBalance: false
        };
    }
}

// 全局实例
window.roguelikeSystem = new RoguelikeSystem();

console.log('肉鸽系统已加载');